package com.lfz.demo.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lfz.demo.entity.LineTrend;
import com.lfz.demo.entity.ChinaPopulation;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * @author lfz
 * @date 2025/2/24 18:10
 */
public interface IndexMapper extends BaseMapper<ChinaPopulation> {

    /**
     * 接口：只有方法定义，写业务逻辑
     * 三种实现方法：
     * 1、写实现类，写你的业务逻辑
     * 2、XML    mybatisplus 一种实现
     * 3、@Select
     */

    // 查询所有的城市名称，常住人口，统计截止时间，普查时间描述
    @Select("select city_name,population,update_time,census_time from china_population")
    List<ChinaPopulation> findChinaPopulation();

    // 根据普查时间查询数据并按常住人口从多到少排序
    @Select("SELECT * FROM china_population WHERE census_time = #{censusTime} ORDER BY population DESC")
    List<ChinaPopulation> findByCensusTime(@Param("censusTime") String censusTime);


}
